package com.wbcs.system.inputbox;

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

import com.wbcs.config.xml.XmlElementBean;
import com.wbcs.system.component.application.report.abstractreport.AbsReportType;

public class PasswordBox extends TextBox
{
    private static Log log=LogFactory.getLog(PasswordBox.class);
    
    private int encodelength;
    
    public PasswordBox(String typename)
    {
        super(typename);
    }

    public int getEncodelength()
    {
        return encodelength;
    }

    @Override
	public String getInputboxInnerType()
    {
        return "password";
    }

    @Override
	public void setDefaultFillmode(AbsReportType reportTypeObj)
    {
        this.fillmode=1;
    }

    @Override
	public void loadInputBoxConfig(IInputBoxOwnerBean ownerbean,XmlElementBean eleInputboxBean)
    {
        super.loadInputBoxConfig(ownerbean,eleInputboxBean);
        if(eleInputboxBean==null) return;
        String strencodelength=eleInputboxBean.attributeValue("encodelength");
        if(strencodelength!=null)
        {
            strencodelength=strencodelength.trim();
            if(strencodelength.equals(""))
            {
                this.encodelength=0;
            }else
            {
                try
                {
                    this.encodelength=Integer.parseInt(strencodelength);
                }catch(NumberFormatException e)
                {
                    log.warn("为密码框配置的encodelength属性值："+strencodelength+"不是有效数字");
                    this.encodelength=0;
                }
                if(this.encodelength<5)
                {
                    log.warn("为密码框配置的encodelength属性值："+strencodelength+"小于5，将采用5做为编码长度");
                    this.encodelength=5;
                }
            }
        }
    }

    @Override
	public void doPostLoad(IInputBoxOwnerBean ownerbean)
    {
        this.setTypePromptBean(null);
        super.doPostLoad(ownerbean);
    }
}
